#coding=GBK
'''
Created on 4 Mar 2013

@author: R
'''

import os

ffmpeg = 'D:\\prog\\ffmpeg\\bin\\ffmpeg.exe'
#file_name = 'D:\\prog\\Pyrrhic\\JJ-009.avi'
file_name = 'F:\\0MTV\\The.Chorus.2004.BD.2Audio.MiNiSD-TLF.mkv'
#save_name = os.path.dirname(file_name)+os.path.sep+'copy_'+os.path.basename(file_name)
save_name = 'D:\\a.mkv'

#time in sec or 00:10:00
start_time = '100' 
last_time = '10'

    
def cut_video():
    para = ' -ss '+start_time \
           +' -i '+file_name \
           +' -vcodec copy' \
           +' -acodec copy' \
           +' -t '+last_time \
           +' -y ' \
           +' '+save_name
    os.system(ffmpeg+para)

def cut_mp3():
    para = ' -i '
    os.system(ffmpeg+para)

def save_img():
    para = ' -i '
    os.system(ffmpeg+para)

def save_mp3():
    para = ' -ss '+start_time \
           +' -i '+file_name \
           +' -vn' \
           +' -f mp3 ' \
           +' -t '+last_time \
           +' -y ' \
           +' '+save_name
    os.system(ffmpeg+para)

def join_video():
    '''
        ffmpeg  -i INPUT -f mpeg  OUTPUT
        copy -b INPUT+INPUT OUTPUT
        ffmpeg -i INPUT -f FORMAT OUTPUT
    '''
    file_name = 'F:\\0MTV\\20.mkv|F:\\0MTV\\21.mkv'
    para = ' -i concat:'+file_name \
           +' -vcodec copy' \
           +' -acodec copy' \
           +' -y ' \
           +' '+save_name
    os.system(ffmpeg+para)

def join_video_and_audio():
    pass

def img2mp4():
    '''
        -r n:n frames per sec
        -b n:n bits per sec
    '''
    para = ' -f image2 ' \
           '-i c:\\temp\\%02d.jpg ' \
           '-vcodec libx264 ' \
           '-r 10 ' \
           '-b 200k ' \
           'd:\\a.mp4'
    os.system(ffmpeg+para)

if __name__=='__main__':
    #join_video()
